///
/// This sub is called when a record is getting saved. Call base.SaveData()
/// only if duplicate record is not present in the database.
///
public override void SaveData()
{
string whereStr = ${${Table Name}ClassName}.${Primary Key}.UniqueName + " = '" + this.${Primary Key Control}.Text + "'";
// Check if record already exists before saving.
${${Table Name}RecordClassName} rec = ${${Table Name}ClassName}.GetRecord(whereStr);
if (rec != null)
{
// If record exists, do not save the record
}
else
{
// Save the record if it does not exists
base.SaveData();
}
}
|